package com.project.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.TopicBean;
import com.project.mapper.ITopicMapper;
import com.project.service.ITopicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;

@Service
@Transactional
public class ITopicServiceImpl implements ITopicService {
    @Autowired
    private ITopicMapper mapper;

    @Override
    public PageInfo<TopicBean> findByItem(int channelId, int pageNo, String name, String author, LocalDateTime startDate, LocalDateTime endDate) {
        PageHelper.startPage(pageNo,3);
        PageInfo<TopicBean>pageInfo=PageInfo.of(mapper.findByItem(channelId,name,author,startDate,endDate));
        return pageInfo;
    }

    @Override
    public void add(TopicBean topic) {
        mapper.add(topic);
    }

    @Override
    public TopicBean findById(int id) {
        return mapper.findById(id);
    }
}
